/*
 Navicat Premium Data Transfer

 Source Server         : 31.142
 Source Server Type    : MySQL
 Source Server Version : 80024
 Source Host           : 192.168.31.142:3306
 Source Schema         : lg_seckill

 Target Server Type    : MySQL
 Target Server Version : 80024
 File Encoding         : 65001

 Date: 21/08/2021 22:27:22
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
  `product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品id',
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '商品名称',
  `number` int DEFAULT NULL COMMENT '商品数量',
  `detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '商品详细',
  `price` decimal(10,2) DEFAULT NULL COMMENT '单价',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`product_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=114 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品表';

-- ----------------------------
-- Records of product
-- ----------------------------
BEGIN;
INSERT INTO `product` VALUES (111, '西部数据（WD）USB3.0移动硬盘1t/500g/2t/3t/4t/5t 新元素2.5英寸西数硬盘 4TB / WDBU6Y0040BBK 标配 出厂配置+硬盘包', 100, '主体\n品牌\n西部数据 Western Digital\n型号\nWDBU6Y0040BBK\n外壳材质\n塑料\n系列\nElements\n颜色\n黑色\n规格\n产品净重（g）\n230\n电源类型\n不带电源\n指示灯\n有指示灯\n产品尺寸（mm）\n110\n外部加密功能\n不支持外部加密\n支持系统\nXP；MAC；win7；win8；Win10', 699.00, '2021-08-17 10:08:15');
COMMIT;

-- ----------------------------
-- Table structure for seckill_order
-- ----------------------------
DROP TABLE IF EXISTS `seckill_order`;
CREATE TABLE `seckill_order` (
  `seckill_order_id` bigint NOT NULL AUTO_INCREMENT,
  `seckill_id` bigint DEFAULT NULL COMMENT '秒杀商品id',
  `product_id` bigint DEFAULT NULL COMMENT '商品id',
  `seckill_number` int DEFAULT NULL COMMENT '数量',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `pay_status` int DEFAULT '0' COMMENT '付款状态',
  `pay_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '支付类型',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`seckill_order_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=626583084011368449 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='秒杀订单表';

-- ----------------------------
-- Records of seckill_order
-- ----------------------------
BEGIN;
INSERT INTO `seckill_order` VALUES (626582641088671744, 1, 111, 1, 11, 1, 'aliPay', '2021-08-21 22:16:49');
INSERT INTO `seckill_order` VALUES (626582817417211904, 1, 111, 1, 11, 2, '', '2021-08-21 22:17:31');
INSERT INTO `seckill_order` VALUES (626582978285547520, 1, 111, 1, 11, 2, '', '2021-08-21 22:18:09');
INSERT INTO `seckill_order` VALUES (626583084011368448, 1, 111, 1, 11, 1, 'aliPay', '2021-08-21 22:18:34');
COMMIT;

-- ----------------------------
-- Table structure for seckill_product
-- ----------------------------
DROP TABLE IF EXISTS `seckill_product`;
CREATE TABLE `seckill_product` (
  `seckill_product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '秒杀id',
  `product_id` bigint NOT NULL DEFAULT '0' COMMENT '商品id',
  `number` int NOT NULL DEFAULT '0' COMMENT '库存数量',
  `seckill_price` decimal(10,2) NOT NULL COMMENT '秒杀单价',
  `start_time` timestamp NOT NULL COMMENT '开始时间',
  `end_time` timestamp NOT NULL COMMENT '结束时间',
  `create_time` timestamp NOT NULL COMMENT '创建时间',
  `status` int DEFAULT '0' COMMENT '秒杀状态，0未开始，1数据已经预热，2秒杀结束',
  PRIMARY KEY (`seckill_product_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='秒杀库存表';

-- ----------------------------
-- Records of seckill_product
-- ----------------------------
BEGIN;
INSERT INTO `seckill_product` VALUES (1, 111, 98, 599.00, '2021-08-21 22:13:00', '2021-08-21 22:59:59', '2021-08-17 11:31:03', 1);
COMMIT;

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` (
  `user_id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户id',
  `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户名',
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
  `nick_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '昵称',
  `phone_number` varbinary(15) DEFAULT '' COMMENT '手机号',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户表';

-- ----------------------------
-- Records of sys_user
-- ----------------------------
BEGIN;
INSERT INTO `sys_user` VALUES (11, 'zhangsan', '123456', '张三', 0x3133383030313338303030);
INSERT INTO `sys_user` VALUES (21, 'lisi', '123456', '李四', 0x3133383030313338303031);
INSERT INTO `sys_user` VALUES (31, '老王', '123456', '老王', 0x3133383030313338303032);
COMMIT;

-- ----------------------------
-- View structure for seckill_product_info_view
-- ----------------------------
DROP VIEW IF EXISTS `seckill_product_info_view`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `seckill_product_info_view` AS select `sp`.`seckill_product_id` AS `seckill_product_id`,`p`.`product_id` AS `product_id`,`p`.`name` AS `name`,`p`.`detail` AS `detail`,`p`.`price` AS `price`,`sp`.`number` AS `number`,`sp`.`seckill_price` AS `seckill_price`,`sp`.`start_time` AS `start_time`,`sp`.`end_time` AS `end_time`,`sp`.`status` AS `status` from (`seckill_product` `sp` left join `product` `p` on((`sp`.`product_id` = `p`.`product_id`)));

-- ----------------------------
-- View structure for user_seckill_order_view
-- ----------------------------
DROP VIEW IF EXISTS `user_seckill_order_view`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `user_seckill_order_view` AS select `so`.`seckill_order_id` AS `seckill_order_id`,`so`.`seckill_number` AS `seckill_number`,`so`.`pay_status` AS `pay_status`,`so`.`pay_type` AS `pay_type`,`so`.`create_time` AS `create_time`,`su`.`username` AS `username`,`su`.`user_id` AS `user_id`,`sp`.`seckill_price` AS `seckill_price`,`p`.`name` AS `name` from (((`seckill_order` `so` left join `seckill_product` `sp` on((`so`.`seckill_id` = `sp`.`seckill_product_id`))) left join `sys_user` `su` on((`su`.`user_id` = `so`.`user_id`))) left join `product` `p` on((`p`.`product_id` = `sp`.`product_id`)));

SET FOREIGN_KEY_CHECKS = 1;
